package com.bdqn.ch03.factory;

import com.bdqn.ch03.dao.NewDao;
import com.bdqn.ch03.dao.impl.NewDaoMySqlImpl;
import com.bdqn.ch03.dao.impl.NewDaoOracleImpl;
import com.bdqn.ch03.dao.impl.NewsDaoImpl;
import com.bdqn.ch03.dao.impl.NewsDaoRedisImpl;

public class SimpleDaFactory {

    public  static NewDao getInstance(String key){
//        return new NewsDaoImpl();
        switch (key){

            case "mysql":
                return new NewDaoMySqlImpl();
            case "oracle":
                return new NewDaoOracleImpl();
            case "redis":
                return new NewsDaoRedisImpl();
            default:
                throw  new RuntimeException("没有该数据库类型"+key);
        }
    }
}
